package com.metadata_system.api_server.system_server;


import com.metadata_system.api.annotations.CheckTokenUser;
import com.metadata_system.common.dto.ApiResult;
import com.metadata_system.common.enums.AllConst;
import com.metadata_system.common.http.request_dto.LoginUserRequest;
import com.metadata_system.common.utils.MyAesUtils;
import com.metadata_system.system.service.DatabaseService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

@RestController("systemPublicController")
@RequestMapping(value = "/api/system-server/v001/Public/")
@Slf4j
public class PublicController {

    /**
     * 公共字典接口
     * @return
     */
    @SneakyThrows
    @RequestMapping(value = "IavEYIyK")
    public ApiResult IavEYIyK(
            @RequestParam("myKey") String myKey
    ) {
        if(StringUtils.isBlank(myKey)){
            return ApiResult.error("非法请求1");
        }
        try {
            myKey = MyAesUtils.decrypt(myKey,MyAesUtils.KEY);
            if(StringUtils.isBlank(myKey)){
                return ApiResult.error("非法请求2");
            }
        }catch (Exception e){

        }
        Map<String, Object> allConstMap = AllConst.getStaticFields(AllConst.class);
        allConstMap.put("Timestamp", new Date().getTime()*0.001);
        return ApiResult.success(allConstMap);
    }
}
